import requests
from bs4 import BeautifulSoup

headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"
}
r = requests.get("https://www.kugou.com/yy/rank/home/1-8888.html?from=rank",headers = headers)
r.encoding = "utf-8"
soup = BeautifulSoup(r.text,"html.parser")
ranks = soup.select("span.pc_temp_num")
titles = soup.select("div.pc_temp_songlist > ul >li> a")
times = soup.select("span.pc_temp_tips_r > span")
for rank,title,time in zip(ranks,titles,times):
    data = {
        "rank":rank.get_text().strip(),
        "title":title.get_text().split("-"),
        "time":time.get_text().strip()
    }
    data2 = {
        "rank":rank.get_text(),#get_text()获取html标签中的文本
        "title":title.get_text(),
        "time":time.get_text()
    }
    print(data)
    print(data2)

#print(times,ranks,titles)